/*************************************************************************
Purpose: This program tests upward continuation verification stat tests.
**************************************************************************    
Copyright 2010 Bryan Killett

This file is part of GAIA.

GAIA is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

GAIA is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with GAIA. If not, see <http://www.gnu.org/licenses/>.
*************************************************************************/
//Header file "definitions.hpp" declares many functions, constants, datatypes.
//In order to use the functions declared in definitions.hpp, must link
//with object code that includes functions.cpp.
#include "definitions.hpp"

int main(){
  //Variable declarations- every variable type that ends in "_s"
  //is defined in GAIAFOLDER/c/definitions.hpp.
  string options_file(gaiafolder());
  input_s input, unused_input;
  ancillary_s ancillary;
  grid_s region, empty_region;
  grid_s grid;
  model_s model;
  results_s results, regional_results,overlap_results;
  plot_options_s plot_options,temp_options,overlap_plot_options;
  insitu_s insitu;//For tide gauge data, etc.

  timespan_conversion_s timespan_conversion;//From secs to human units

  string temp_string;

  //Used to copy old options file instead of making it in create_options().
  string previous_options_file(gaiafolder());

  //Used to search the overlap folder for filenames of each region's files.
  string newfile;

  //////////////////////////////////////////////////////////////////////////
  //End of variable declarations, start of loading.
  //////////////////////////////////////////////////////////////////////////

  //Location of the options file that create_options() creates
  //and load_options() loads, or the target of the copy operation that
  //loads a previously-generated options file.
  options_file.append("c/options.txt");

  //Load options from file produced by create_options.txt
  load_options(options_file, input, region.options, ancillary, grid, model.options, results, plot_options, insitu,1);

  load_ancillary(ancillary, 1);

  define_grid(grid,ancillary,results);  
  
  //Needs to be 1 - don't have non-region code working...
  region.options.type = 2;

  //Needs to be 1 - don't have sequential code working...
  region.options.parallel = 1;

  //Over-write region with regions specifically chosen for upward cont.
  region.options.noload=0;//Don't bother displaying it.
  region = define_region(region.options, grid, 1);

  //Over-write input because original analysis may have been performed w/
  //no regions, but region code (i.e. binindices vector) is required here
  //because I haven't written upward continuation code without regions.
  load_input(input,grid,region);
  //Don't split input yet because upward continuation should use
  //all input points.  I'll run split_input after the upward_continuation.

  //I want these to both be 0.
  region.options.analysis_list_cache_only = 0;
  region.options.analysis_list_choice = 0;

  //Defines where temporary simulated input file will be saved.
  input.options.output_folder = "data/GRACE/simulations/";
  input.options.output_filename = "input_and_orbit_verification_temp.txt";

  //Now it's time to split the input, so that comparing the two input
  //files will result in some input points counting as inversion points
  //and other input points counting as verification_points.  Shouldn't
  //be done before this point!
  if(input.options.split_input!=0) unused_input=split_input(input,region);

  input.file_comparison_method = 1;
  compare_input_file_to_verification_file(input,grid,results);

}
